

def IsPopOrder(pushV, popV):
    if not pushV or len(pushV) != len(popV):
        return False
    stack = []
    index = 0
    for item in pushV:
        stack.append(item)
        while stack and stack[-1] == popV[index]:
            stack.pop();
            index += 1

    if not stack:
        return True
    else:
        return False
M,N,K=map(int,input().split())
popV=[]
for _ in range(M):
    s=input().split(' ')
    s=list(map(int, s))
    popV.append(s)
pushV=[]
for i in range(1,N+1):
    pushV.append(i)
for popV1 in popV:
    print(IsPopOrder(pushV,popV1))
